3.13.1 \(\int \frac {(c+d \tan (e+f x))^2}{(a+b \tan (e+f x))^2} \, dx\) [1201]

3.13.1.1 Optimal result
3.13.1.2 Mathematica [C] (verified)
3.13.1.3 Rubi [A] (verified)
3.13.1.4 Maple [A] (verified)
3.13.1.5 Fricas [B] (verification not implemented)
3.13.1.6 Sympy [C] (verification not implemented)
3.13.1.7 Maxima [A] (verification not implemented)
3.13.1.8 Giac [B] (verification not implemented)
3.13.1.9 Mupad [B] (verification not implemented)

3.13.1.1 Optimal result

Integrand size = 25, antiderivative size = 126 \[ \int \frac {(c+d \tan (e+f x))^2}{(a+b \tan (e+f x))^2} \, dx=-\frac {(b (c-d)-a (c+d)) (a (c-d)+b (c+d)) x}{\left (a^2+b^2\right )^2}+\frac {2 (b c-a d) (a c+b d) \log (a \cos (e+f x)+b \sin (e+f x))}{\left (a^2+b^2\right )^2 f}-\frac {(b c-a d)^2}{b \left (a^2+b^2\right ) f (a+b \tan (e+f x))} \]

output
-(b*(c-d)-a*(c+d))*(a*(c-d)+b*(c+d))*x/(a^2+b^2)^2+2*(-a*d+b*c)*(a*c+b*d)* 
ln(a*cos(f*x+e)+b*sin(f*x+e))/(a^2+b^2)^2/f-(-a*d+b*c)^2/b/(a^2+b^2)/f/(a+ 
b*tan(f*x+e))
 
3.13.1.2 Mathematica [C] (verified)

Result contains complex when optimal does not.

Time = 2.81 (sec) , antiderivative size = 215, normalized size of antiderivative = 1.71 \[ \int \frac {(c+d \tan (e+f x))^2}{(a+b \tan (e+f x))^2} \, dx=\frac {-\left ((b c-a d) \left (\frac {(i a+b) (c+i d)^2 \log (i-\tan (e+f x))}{a+i b}+\frac {(a+i b) (c-i d)^2 \log (i+\tan (e+f x))}{i a+b}+\frac {4 (-b c+a d) (a c+b d) \log (a+b \tan (e+f x))}{a^2+b^2}\right )\right )+2 d^2 (b c-a d) \tan (e+f x)+2 b d (c+d \tan (e+f x))^2-\frac {2 b^2 (c+d \tan (e+f x))^3}{a+b \tan (e+f x)}}{2 \left (a^2+b^2\right ) (b c-a d) f} \]

input
Integrate[(c + d*Tan[e + f*x])^2/(a + b*Tan[e + f*x])^2,x]
 
output
(-((b*c - a*d)*(((I*a + b)*(c + I*d)^2*Log[I - Tan[e + f*x]])/(a + I*b) + 
((a + I*b)*(c - I*d)^2*Log[I + Tan[e + f*x]])/(I*a + b) + (4*(-(b*c) + a*d 
)*(a*c + b*d)*Log[a + b*Tan[e + f*x]])/(a^2 + b^2))) + 2*d^2*(b*c - a*d)*T 
an[e + f*x] + 2*b*d*(c + d*Tan[e + f*x])^2 - (2*b^2*(c + d*Tan[e + f*x])^3 
)/(a + b*Tan[e + f*x]))/(2*(a^2 + b^2)*(b*c - a*d)*f)
 
3.13.1.3 Rubi [A] (verified)

Time = 0.62 (sec) , antiderivative size = 137, normalized size of antiderivative = 1.09, number of steps used = 6, number of rules used = 6, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.240, Rules used = {3042, 4025, 3042, 4014, 3042, 4013}

Below are the steps used by Rubi to obtain the solution. The rule number used for the transformation is given above next to the arrow. The rules definitions used are listed below.

\(\displaystyle \int \frac {(c+d \tan (e+f x))^2}{(a+b \tan (e+f x))^2} \, dx\)

\(\Big \downarrow \) 3042

\(\displaystyle \int \frac {(c+d \tan (e+f x))^2}{(a+b \tan (e+f x))^2}dx\)

\(\Big \downarrow \) 4025

\(\displaystyle \frac {\int \frac {2 b c d+a \left (c^2-d^2\right )+\left (2 a c d-b \left (c^2-d^2\right )\right ) \tan (e+f x)}{a+b \tan (e+f x)}dx}{a^2+b^2}-\frac {(b c-a d)^2}{b f \left (a^2+b^2\right ) (a+b \tan (e+f x))}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\int \frac {2 b c d+a \left (c^2-d^2\right )+\left (2 a c d-b \left (c^2-d^2\right )\right ) \tan (e+f x)}{a+b \tan (e+f x)}dx}{a^2+b^2}-\frac {(b c-a d)^2}{b f \left (a^2+b^2\right ) (a+b \tan (e+f x))}\)

\(\Big \downarrow \) 4014

\(\displaystyle \frac {\frac {2 (b c-a d) (a c+b d) \int \frac {b-a \tan (e+f x)}{a+b \tan (e+f x)}dx}{a^2+b^2}+\frac {x (a c-a d+b c+b d) (a c+a d-b c+b d)}{a^2+b^2}}{a^2+b^2}-\frac {(b c-a d)^2}{b f \left (a^2+b^2\right ) (a+b \tan (e+f x))}\)

\(\Big \downarrow \) 3042

\(\displaystyle \frac {\frac {2 (b c-a d) (a c+b d) \int \frac {b-a \tan (e+f x)}{a+b \tan (e+f x)}dx}{a^2+b^2}+\frac {x (a c-a d+b c+b d) (a c+a d-b c+b d)}{a^2+b^2}}{a^2+b^2}-\frac {(b c-a d)^2}{b f \left (a^2+b^2\right ) (a+b \tan (e+f x))}\)

\(\Big \downarrow \) 4013

\(\displaystyle \frac {\frac {2 (b c-a d) (a c+b d) \log (a \cos (e+f x)+b \sin (e+f x))}{f \left (a^2+b^2\right )}+\frac {x (a c-a d+b c+b d) (a c+a d-b c+b d)}{a^2+b^2}}{a^2+b^2}-\frac {(b c-a d)^2}{b f \left (a^2+b^2\right ) (a+b \tan (e+f x))}\)

input
Int[(c + d*Tan[e + f*x])^2/(a + b*Tan[e + f*x])^2,x]
 
output
(((a*c + b*c - a*d + b*d)*(a*c - b*c + a*d + b*d)*x)/(a^2 + b^2) + (2*(b*c 
 - a*d)*(a*c + b*d)*Log[a*Cos[e + f*x] + b*Sin[e + f*x]])/((a^2 + b^2)*f)) 
/(a^2 + b^2) - (b*c - a*d)^2/(b*(a^2 + b^2)*f*(a + b*Tan[e + f*x]))
 

3.13.1.3.1 Defintions of rubi rules used

rule 3042
Int[u_, x_Symbol] :> Int[DeactivateTrig[u, x], x] /; FunctionOfTrigOfLinear 
Q[u, x]
 

rule 4013
Int[((c_) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_) + (b_.)*tan[(e_.) + (f_.)* 
(x_)]), x_Symbol] :> Simp[(c/(b*f))*Log[RemoveContent[a*Cos[e + f*x] + b*Si 
n[e + f*x], x]], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && 
 NeQ[a^2 + b^2, 0] && EqQ[a*c + b*d, 0]
 

rule 4014
Int[((c_.) + (d_.)*tan[(e_.) + (f_.)*(x_)])/((a_.) + (b_.)*tan[(e_.) + (f_. 
)*(x_)]), x_Symbol] :> Simp[(a*c + b*d)*(x/(a^2 + b^2)), x] + Simp[(b*c - a 
*d)/(a^2 + b^2)   Int[(b - a*Tan[e + f*x])/(a + b*Tan[e + f*x]), x], x] /; 
FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] && NeQ[a^2 + b^2, 0] && N 
eQ[a*c + b*d, 0]
 

rule 4025
Int[((a_.) + (b_.)*tan[(e_.) + (f_.)*(x_)])^(m_)*((c_.) + (d_.)*tan[(e_.) + 
 (f_.)*(x_)])^2, x_Symbol] :> Simp[(b*c - a*d)^2*((a + b*Tan[e + f*x])^(m + 
 1)/(b*f*(m + 1)*(a^2 + b^2))), x] + Simp[1/(a^2 + b^2)   Int[(a + b*Tan[e 
+ f*x])^(m + 1)*Simp[a*c^2 + 2*b*c*d - a*d^2 - (b*c^2 - 2*a*c*d - b*d^2)*Ta 
n[e + f*x], x], x], x] /; FreeQ[{a, b, c, d, e, f}, x] && NeQ[b*c - a*d, 0] 
 && LtQ[m, -1] && NeQ[a^2 + b^2, 0]
 
3.13.1.4 Maple [A] (verified)

Time = 0.24 (sec) , antiderivative size = 200, normalized size of antiderivative = 1.59

method result size
derivativedivides \(\frac {\frac {\frac {\left (2 a^{2} c d -2 a b \,c^{2}+2 a b \,d^{2}-2 b^{2} c d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (a^{2} c^{2}-a^{2} d^{2}+4 a b c d -b^{2} c^{2}+b^{2} d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}-\frac {a^{2} d^{2}-2 a b c d +b^{2} c^{2}}{\left (a^{2}+b^{2}\right ) b \left (a +b \tan \left (f x +e \right )\right )}-\frac {2 \left (a^{2} c d -a b \,c^{2}+a b \,d^{2}-b^{2} c d \right ) \ln \left (a +b \tan \left (f x +e \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}}{f}\) \(200\)
default \(\frac {\frac {\frac {\left (2 a^{2} c d -2 a b \,c^{2}+2 a b \,d^{2}-2 b^{2} c d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (a^{2} c^{2}-a^{2} d^{2}+4 a b c d -b^{2} c^{2}+b^{2} d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}-\frac {a^{2} d^{2}-2 a b c d +b^{2} c^{2}}{\left (a^{2}+b^{2}\right ) b \left (a +b \tan \left (f x +e \right )\right )}-\frac {2 \left (a^{2} c d -a b \,c^{2}+a b \,d^{2}-b^{2} c d \right ) \ln \left (a +b \tan \left (f x +e \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}}{f}\) \(200\)
norman \(\frac {\frac {a \left (a^{2} c^{2}-a^{2} d^{2}+4 a b c d -b^{2} c^{2}+b^{2} d^{2}\right ) x}{a^{4}+2 a^{2} b^{2}+b^{4}}+\frac {b \left (a^{2} c^{2}-a^{2} d^{2}+4 a b c d -b^{2} c^{2}+b^{2} d^{2}\right ) x \tan \left (f x +e \right )}{a^{4}+2 a^{2} b^{2}+b^{4}}+\frac {\left (a^{2} d^{2}-2 a b c d +b^{2} c^{2}\right ) \tan \left (f x +e \right )}{a f \left (a^{2}+b^{2}\right )}}{a +b \tan \left (f x +e \right )}+\frac {\left (a^{2} c d -a b \,c^{2}+a b \,d^{2}-b^{2} c d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {2 \left (a^{2} c d -a b \,c^{2}+a b \,d^{2}-b^{2} c d \right ) \ln \left (a +b \tan \left (f x +e \right )\right )}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}\) \(298\)
parallelrisch \(\frac {\tan \left (f x +e \right ) b^{4} c^{2}+\tan \left (f x +e \right ) a^{4} d^{2}+2 \ln \left (a +b \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) a^{2} b^{2} c^{2}-2 \ln \left (a +b \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) a^{2} b^{2} d^{2}+2 \ln \left (a +b \tan \left (f x +e \right )\right ) a^{2} b^{2} c d +\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) a^{4} c d -\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) a^{3} b \,c^{2}+\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) a^{3} b \,d^{2}-\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) a^{2} b^{2} c d -\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) \tan \left (f x +e \right ) a^{2} b^{2} c^{2}+\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) \tan \left (f x +e \right ) a^{2} b^{2} d^{2}-x \,a^{2} b^{2} c^{2} f +x \,a^{2} b^{2} d^{2} f -2 \tan \left (f x +e \right ) a^{3} b c d -2 \tan \left (f x +e \right ) a \,b^{3} c d +x \,a^{4} c^{2} f -x \,a^{4} d^{2} f +\tan \left (f x +e \right ) a^{2} b^{2} c^{2}+\tan \left (f x +e \right ) a^{2} b^{2} d^{2}-2 \ln \left (a +b \tan \left (f x +e \right )\right ) a^{4} c d +2 \ln \left (a +b \tan \left (f x +e \right )\right ) a^{3} b \,c^{2}-2 \ln \left (a +b \tan \left (f x +e \right )\right ) a^{3} b \,d^{2}+\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) \tan \left (f x +e \right ) a^{3} b c d -\ln \left (1+\tan ^{2}\left (f x +e \right )\right ) \tan \left (f x +e \right ) a \,b^{3} c d -2 \ln \left (a +b \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) a^{3} b c d +2 \ln \left (a +b \tan \left (f x +e \right )\right ) \tan \left (f x +e \right ) a \,b^{3} c d -x \tan \left (f x +e \right ) a \,b^{3} c^{2} f +4 x \,a^{3} b c d f +x \tan \left (f x +e \right ) a \,b^{3} d^{2} f +x \tan \left (f x +e \right ) a^{3} b \,c^{2} f -x \tan \left (f x +e \right ) a^{3} b \,d^{2} f +4 x \tan \left (f x +e \right ) a^{2} b^{2} c d f}{\left (a +b \tan \left (f x +e \right )\right ) \left (a^{2}+b^{2}\right )^{2} a f}\) \(620\)
risch \(-\frac {4 i a b c d}{\left (i b +a \right ) f \left (-i b +a \right )^{2} \left (-i {\mathrm e}^{2 i \left (f x +e \right )} b +{\mathrm e}^{2 i \left (f x +e \right )} a +i b +a \right )}-\frac {x \,c^{2}}{2 i a b -a^{2}+b^{2}}+\frac {x \,d^{2}}{2 i a b -a^{2}+b^{2}}+\frac {2 i b^{2} c^{2}}{\left (i b +a \right ) f \left (-i b +a \right )^{2} \left (-i {\mathrm e}^{2 i \left (f x +e \right )} b +{\mathrm e}^{2 i \left (f x +e \right )} a +i b +a \right )}-\frac {4 i x \,b^{2} c d}{a^{4}+2 a^{2} b^{2}+b^{4}}+\frac {2 i x c d}{2 i a b -a^{2}+b^{2}}+\frac {4 i a^{2} c d e}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {4 i x a b \,c^{2}}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {4 i b^{2} c d e}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}+\frac {2 i a^{2} d^{2}}{\left (i b +a \right ) f \left (-i b +a \right )^{2} \left (-i {\mathrm e}^{2 i \left (f x +e \right )} b +{\mathrm e}^{2 i \left (f x +e \right )} a +i b +a \right )}+\frac {4 i a b \,d^{2} e}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {4 i a b \,c^{2} e}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}+\frac {4 i x \,a^{2} c d}{a^{4}+2 a^{2} b^{2}+b^{4}}+\frac {4 i x a b \,d^{2}}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i b +a}{i b -a}\right ) a^{2} c d}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}+\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i b +a}{i b -a}\right ) a b \,c^{2}}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i b +a}{i b -a}\right ) a b \,d^{2}}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}+\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i b +a}{i b -a}\right ) b^{2} c d}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}\) \(689\)

input
int((c+d*tan(f*x+e))^2/(a+b*tan(f*x+e))^2,x,method=_RETURNVERBOSE)
 
output
1/f*(1/(a^2+b^2)^2*(1/2*(2*a^2*c*d-2*a*b*c^2+2*a*b*d^2-2*b^2*c*d)*ln(1+tan 
(f*x+e)^2)+(a^2*c^2-a^2*d^2+4*a*b*c*d-b^2*c^2+b^2*d^2)*arctan(tan(f*x+e))) 
-(a^2*d^2-2*a*b*c*d+b^2*c^2)/(a^2+b^2)/b/(a+b*tan(f*x+e))-2*(a^2*c*d-a*b*c 
^2+a*b*d^2-b^2*c*d)/(a^2+b^2)^2*ln(a+b*tan(f*x+e)))
 
3.13.1.5 Fricas [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 304 vs. \(2 (125) = 250\).

Time = 0.26 (sec) , antiderivative size = 304, normalized size of antiderivative = 2.41 \[ \int \frac {(c+d \tan (e+f x))^2}{(a+b \tan (e+f x))^2} \, dx=-\frac {b^{3} c^{2} - 2 \, a b^{2} c d + a^{2} b d^{2} - {\left (4 \, a^{2} b c d + {\left (a^{3} - a b^{2}\right )} c^{2} - {\left (a^{3} - a b^{2}\right )} d^{2}\right )} f x - {\left (a^{2} b c^{2} - a^{2} b d^{2} - {\left (a^{3} - a b^{2}\right )} c d + {\left (a b^{2} c^{2} - a b^{2} d^{2} - {\left (a^{2} b - b^{3}\right )} c d\right )} \tan \left (f x + e\right )\right )} \log \left (\frac {b^{2} \tan \left (f x + e\right )^{2} + 2 \, a b \tan \left (f x + e\right ) + a^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) - {\left (a b^{2} c^{2} - 2 \, a^{2} b c d + a^{3} d^{2} + {\left (4 \, a b^{2} c d + {\left (a^{2} b - b^{3}\right )} c^{2} - {\left (a^{2} b - b^{3}\right )} d^{2}\right )} f x\right )} \tan \left (f x + e\right )}{{\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} f \tan \left (f x + e\right ) + {\left (a^{5} + 2 \, a^{3} b^{2} + a b^{4}\right )} f} \]

input
integrate((c+d*tan(f*x+e))^2/(a+b*tan(f*x+e))^2,x, algorithm="fricas")
 
output
-(b^3*c^2 - 2*a*b^2*c*d + a^2*b*d^2 - (4*a^2*b*c*d + (a^3 - a*b^2)*c^2 - ( 
a^3 - a*b^2)*d^2)*f*x - (a^2*b*c^2 - a^2*b*d^2 - (a^3 - a*b^2)*c*d + (a*b^ 
2*c^2 - a*b^2*d^2 - (a^2*b - b^3)*c*d)*tan(f*x + e))*log((b^2*tan(f*x + e) 
^2 + 2*a*b*tan(f*x + e) + a^2)/(tan(f*x + e)^2 + 1)) - (a*b^2*c^2 - 2*a^2* 
b*c*d + a^3*d^2 + (4*a*b^2*c*d + (a^2*b - b^3)*c^2 - (a^2*b - b^3)*d^2)*f* 
x)*tan(f*x + e))/((a^4*b + 2*a^2*b^3 + b^5)*f*tan(f*x + e) + (a^5 + 2*a^3* 
b^2 + a*b^4)*f)
 
3.13.1.6 Sympy [C] (verification not implemented)

Result contains complex when optimal does not.

Time = 0.86 (sec) , antiderivative size = 4258, normalized size of antiderivative = 33.79 \[ \int \frac {(c+d \tan (e+f x))^2}{(a+b \tan (e+f x))^2} \, dx=\text {Too large to display} \]

input
integrate((c+d*tan(f*x+e))**2/(a+b*tan(f*x+e))**2,x)
 
output
Piecewise((zoo*x*(c + d*tan(e))**2/tan(e)**2, Eq(a, 0) & Eq(b, 0) & Eq(f, 
0)), ((c**2*x + c*d*log(tan(e + f*x)**2 + 1)/f - d**2*x + d**2*tan(e + f*x 
)/f)/a**2, Eq(b, 0)), (-c**2*f*x*tan(e + f*x)**2/(4*b**2*f*tan(e + f*x)**2 
 - 8*I*b**2*f*tan(e + f*x) - 4*b**2*f) + 2*I*c**2*f*x*tan(e + f*x)/(4*b**2 
*f*tan(e + f*x)**2 - 8*I*b**2*f*tan(e + f*x) - 4*b**2*f) + c**2*f*x/(4*b** 
2*f*tan(e + f*x)**2 - 8*I*b**2*f*tan(e + f*x) - 4*b**2*f) - c**2*tan(e + f 
*x)/(4*b**2*f*tan(e + f*x)**2 - 8*I*b**2*f*tan(e + f*x) - 4*b**2*f) + 2*I* 
c**2/(4*b**2*f*tan(e + f*x)**2 - 8*I*b**2*f*tan(e + f*x) - 4*b**2*f) + 2*I 
*c*d*f*x*tan(e + f*x)**2/(4*b**2*f*tan(e + f*x)**2 - 8*I*b**2*f*tan(e + f* 
x) - 4*b**2*f) + 4*c*d*f*x*tan(e + f*x)/(4*b**2*f*tan(e + f*x)**2 - 8*I*b* 
*2*f*tan(e + f*x) - 4*b**2*f) - 2*I*c*d*f*x/(4*b**2*f*tan(e + f*x)**2 - 8* 
I*b**2*f*tan(e + f*x) - 4*b**2*f) + 2*I*c*d*tan(e + f*x)/(4*b**2*f*tan(e + 
 f*x)**2 - 8*I*b**2*f*tan(e + f*x) - 4*b**2*f) + d**2*f*x*tan(e + f*x)**2/ 
(4*b**2*f*tan(e + f*x)**2 - 8*I*b**2*f*tan(e + f*x) - 4*b**2*f) - 2*I*d**2 
*f*x*tan(e + f*x)/(4*b**2*f*tan(e + f*x)**2 - 8*I*b**2*f*tan(e + f*x) - 4* 
b**2*f) - d**2*f*x/(4*b**2*f*tan(e + f*x)**2 - 8*I*b**2*f*tan(e + f*x) - 4 
*b**2*f) - 3*d**2*tan(e + f*x)/(4*b**2*f*tan(e + f*x)**2 - 8*I*b**2*f*tan( 
e + f*x) - 4*b**2*f) + 2*I*d**2/(4*b**2*f*tan(e + f*x)**2 - 8*I*b**2*f*tan 
(e + f*x) - 4*b**2*f), Eq(a, -I*b)), (-c**2*f*x*tan(e + f*x)**2/(4*b**2*f* 
tan(e + f*x)**2 + 8*I*b**2*f*tan(e + f*x) - 4*b**2*f) - 2*I*c**2*f*x*ta...
 
3.13.1.7 Maxima [A] (verification not implemented)

Time = 0.33 (sec) , antiderivative size = 230, normalized size of antiderivative = 1.83 \[ \int \frac {(c+d \tan (e+f x))^2}{(a+b \tan (e+f x))^2} \, dx=\frac {\frac {{\left (4 \, a b c d + {\left (a^{2} - b^{2}\right )} c^{2} - {\left (a^{2} - b^{2}\right )} d^{2}\right )} {\left (f x + e\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac {2 \, {\left (a b c^{2} - a b d^{2} - {\left (a^{2} - b^{2}\right )} c d\right )} \log \left (b \tan \left (f x + e\right ) + a\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac {{\left (a b c^{2} - a b d^{2} - {\left (a^{2} - b^{2}\right )} c d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac {b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}}{a^{3} b + a b^{3} + {\left (a^{2} b^{2} + b^{4}\right )} \tan \left (f x + e\right )}}{f} \]

input
integrate((c+d*tan(f*x+e))^2/(a+b*tan(f*x+e))^2,x, algorithm="maxima")
 
output
((4*a*b*c*d + (a^2 - b^2)*c^2 - (a^2 - b^2)*d^2)*(f*x + e)/(a^4 + 2*a^2*b^ 
2 + b^4) + 2*(a*b*c^2 - a*b*d^2 - (a^2 - b^2)*c*d)*log(b*tan(f*x + e) + a) 
/(a^4 + 2*a^2*b^2 + b^4) - (a*b*c^2 - a*b*d^2 - (a^2 - b^2)*c*d)*log(tan(f 
*x + e)^2 + 1)/(a^4 + 2*a^2*b^2 + b^4) - (b^2*c^2 - 2*a*b*c*d + a^2*d^2)/( 
a^3*b + a*b^3 + (a^2*b^2 + b^4)*tan(f*x + e)))/f
 
3.13.1.8 Giac [B] (verification not implemented)

Leaf count of result is larger than twice the leaf count of optimal. 324 vs. \(2 (125) = 250\).

Time = 0.51 (sec) , antiderivative size = 324, normalized size of antiderivative = 2.57 \[ \int \frac {(c+d \tan (e+f x))^2}{(a+b \tan (e+f x))^2} \, dx=\frac {\frac {{\left (a^{2} c^{2} - b^{2} c^{2} + 4 \, a b c d - a^{2} d^{2} + b^{2} d^{2}\right )} {\left (f x + e\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac {{\left (a b c^{2} - a^{2} c d + b^{2} c d - a b d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac {2 \, {\left (a b^{2} c^{2} - a^{2} b c d + b^{3} c d - a b^{2} d^{2}\right )} \log \left ({\left | b \tan \left (f x + e\right ) + a \right |}\right )}{a^{4} b + 2 \, a^{2} b^{3} + b^{5}} - \frac {2 \, a b^{3} c^{2} \tan \left (f x + e\right ) - 2 \, a^{2} b^{2} c d \tan \left (f x + e\right ) + 2 \, b^{4} c d \tan \left (f x + e\right ) - 2 \, a b^{3} d^{2} \tan \left (f x + e\right ) + 3 \, a^{2} b^{2} c^{2} + b^{4} c^{2} - 4 \, a^{3} b c d + a^{4} d^{2} - a^{2} b^{2} d^{2}}{{\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} {\left (b \tan \left (f x + e\right ) + a\right )}}}{f} \]

input
integrate((c+d*tan(f*x+e))^2/(a+b*tan(f*x+e))^2,x, algorithm="giac")
 
output
((a^2*c^2 - b^2*c^2 + 4*a*b*c*d - a^2*d^2 + b^2*d^2)*(f*x + e)/(a^4 + 2*a^ 
2*b^2 + b^4) - (a*b*c^2 - a^2*c*d + b^2*c*d - a*b*d^2)*log(tan(f*x + e)^2 
+ 1)/(a^4 + 2*a^2*b^2 + b^4) + 2*(a*b^2*c^2 - a^2*b*c*d + b^3*c*d - a*b^2* 
d^2)*log(abs(b*tan(f*x + e) + a))/(a^4*b + 2*a^2*b^3 + b^5) - (2*a*b^3*c^2 
*tan(f*x + e) - 2*a^2*b^2*c*d*tan(f*x + e) + 2*b^4*c*d*tan(f*x + e) - 2*a* 
b^3*d^2*tan(f*x + e) + 3*a^2*b^2*c^2 + b^4*c^2 - 4*a^3*b*c*d + a^4*d^2 - a 
^2*b^2*d^2)/((a^4*b + 2*a^2*b^3 + b^5)*(b*tan(f*x + e) + a)))/f
 
3.13.1.9 Mupad [B] (verification not implemented)

Time = 8.80 (sec) , antiderivative size = 208, normalized size of antiderivative = 1.65 \[ \int \frac {(c+d \tan (e+f x))^2}{(a+b \tan (e+f x))^2} \, dx=\frac {\ln \left (a+b\,\mathrm {tan}\left (e+f\,x\right )\right )\,\left (-2\,c\,d\,a^2+\left (2\,c^2-2\,d^2\right )\,a\,b+2\,c\,d\,b^2\right )}{f\,\left (a^4+2\,a^2\,b^2+b^4\right )}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )\,\left (c^2+c\,d\,2{}\mathrm {i}-d^2\right )}{2\,f\,\left (-a^2\,1{}\mathrm {i}+2\,a\,b+b^2\,1{}\mathrm {i}\right )}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (c^2\,1{}\mathrm {i}+2\,c\,d-d^2\,1{}\mathrm {i}\right )}{2\,f\,\left (-a^2+a\,b\,2{}\mathrm {i}+b^2\right )}-\frac {a^2\,d^2-2\,a\,b\,c\,d+b^2\,c^2}{b\,f\,\left (a^2+b^2\right )\,\left (a+b\,\mathrm {tan}\left (e+f\,x\right )\right )} \]

input
int((c + d*tan(e + f*x))^2/(a + b*tan(e + f*x))^2,x)
 
output
(log(a + b*tan(e + f*x))*(a*b*(2*c^2 - 2*d^2) - 2*a^2*c*d + 2*b^2*c*d))/(f 
*(a^4 + b^4 + 2*a^2*b^2)) - (log(tan(e + f*x) - 1i)*(c*d*2i + c^2 - d^2))/ 
(2*f*(2*a*b - a^2*1i + b^2*1i)) - (log(tan(e + f*x) + 1i)*(2*c*d + c^2*1i 
- d^2*1i))/(2*f*(a*b*2i - a^2 + b^2)) - (a^2*d^2 + b^2*c^2 - 2*a*b*c*d)/(b 
*f*(a^2 + b^2)*(a + b*tan(e + f*x)))